package cn.pzhuweb.controller;

import cn.pzhuweb.pojo.User;
import cn.pzhuweb.tool.SpringBootBeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author KK
 * @create 2022/3/3 18:08
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping(value = "/{id}")
    public String getById(@PathVariable Integer id) {
        System.out.println("ID" + id);
        return "{'module':'user getById'}";
    }

    @PostMapping
    public String save(@RequestBody User user) {
        System.out.println("user save..." + user);
        return "{'module':'user save'}";
    }

    @DeleteMapping(value = "/{id}")
    public String delete(@PathVariable Integer id) {
        System.out.println(id);
        return "{'module':'user delete'}";
    }

    @PutMapping
    public String update(@RequestBody User user) {
        System.out.println(user);
        return  "{'module':'user update'}";
    }

}
